﻿using Dispatch.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Dispatch.DispatchData
{


    internal class RouteDataSet
    {
        static List<RouteModel> routeList = new List<RouteModel>();

        public static void FillData(List<RouteModel> list)
        {
            lock (routeList)
            {
                routeList.Clear();
                routeList.AddRange(list);
            }
        }


        /// <summary>
        /// 获取可用的路线（多条）
        /// </summary>
        /// <param name="SourceMarker"></param>
        /// <returns></returns>
        public static  int  GetRoute(string SourceMarker)
        {
            var route = routeList.Where(x => x.SourceMarker == SourceMarker).Select(x => x.RouteID).FirstOrDefault();
            return route;
        }

     

        /// <summary>
        /// 获取两个marker之间的路线
        /// </summary>
        /// <param name="StartMarker"></param>
        /// <param name="EndMarker"></param>
        /// <returns></returns>
        public static int  GetRoute(string SourceMarker, string TargetMarker)
        {
            int  route = routeList.Where(x => x.SourceMarker == SourceMarker && x.TargetMarker == TargetMarker).Select(x => x.RouteID).FirstOrDefault();
            return route;
        }

    }
}
